﻿using System;
using System.Threading.Tasks;

namespace Task返回值
{
    class Program
    {
        static void Main(string[] args)
        {
            var task1 = Task.Factory.StartNew(() =>
            {
                return 100;
            });
            var task2 = Task.Factory.StartNew(() =>
            {
                return 200;
            });
            //var task = task1.ContinueWith<string>(t => {
            //    int n = t.Result;
            //    return (++n).ToString();
            //});
            //Console.WriteLine( task.Result);

            var task = Task.WhenAll<int>(new Task<int>[2] { task1, task2 });
            foreach (var t in task.Result)
            {
                Console.WriteLine(t);
            }

            
            Console.Read();
        }
    }
}
